
package sys.donto.telas;

import java.util.List;
import javax.swing.JOptionPane;
import sys.donto.anamnese.Anamnese;
import sys.donto.anamnese.AnamneseDAO;
import sys.donto.anamnese.AnamneseTableModel;
import sys.donto.paciente.Paciente;
import sys.donto.paciente.PacienteDAO;
import sys.donto.paciente.PacienteTableModel;
import sys.donto.util.Util;

/**
 *
 * @author JOABB
 */
public class telaAnamnese extends javax.swing.JDialog {
    private Anamnese anamnese;

    /**
     * Creates new form telaAnamnese
     */
    public telaAnamnese() {
        initComponents();
        setLocationRelativeTo(null);
        setModal(true);
        setTitle("sysDONTO - Cadastro de Anamnese de Paciente");
        limpaCampos();
               
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        tfPaciente = new javax.swing.JTextField();
        btExcluir = new javax.swing.JButton();
        btNovo1 = new javax.swing.JButton();
        btSalvar1 = new javax.swing.JButton();
        btSair1 = new javax.swing.JButton();
        btPesquisar = new javax.swing.JButton();
        btPesquisarPaciente1 = new javax.swing.JButton();
        btNovoPaciente1 = new javax.swing.JButton();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        jlPaciente1 = new javax.swing.JLabel();
        jLabel1 = new javax.swing.JLabel();
        tfSangue = new javax.swing.JTextField();
        cbDoenca = new javax.swing.JComboBox();
        tfQueixa = new javax.swing.JTextField();
        jLabel9 = new javax.swing.JLabel();
        cbTratamento = new javax.swing.JComboBox();
        tfTratamento = new javax.swing.JTextField();
        jLabel10 = new javax.swing.JLabel();
        cbMedicamentos = new javax.swing.JComboBox();
        tfMedicamento = new javax.swing.JTextField();
        jLabel12 = new javax.swing.JLabel();
        cbAntecedentes = new javax.swing.JComboBox();
        tfAntecedentes = new javax.swing.JTextField();
        jLabel15 = new javax.swing.JLabel();
        cbAlergia = new javax.swing.JComboBox();
        tfAlergia = new javax.swing.JTextField();
        jLabel14 = new javax.swing.JLabel();
        jComboBox5 = new javax.swing.JComboBox();
        cbHemorragia = new javax.swing.JComboBox();
        cbAnestesia = new javax.swing.JComboBox();
        cbCicatricacao = new javax.swing.JComboBox();
        jLabel17 = new javax.swing.JLabel();
        jLabel18 = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        tfObservacoes = new javax.swing.JTextPane();
        jLabel19 = new javax.swing.JLabel();
        cbHipertensao = new javax.swing.JComboBox();
        jLabel21 = new javax.swing.JLabel();
        cbRespiratorio = new javax.swing.JComboBox();
        jLabel23 = new javax.swing.JLabel();
        cbCirurgia = new javax.swing.JComboBox();
        tfDoenca = new javax.swing.JTextField();
        jLabel24 = new javax.swing.JLabel();
        jLabel25 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        jLabel20 = new javax.swing.JLabel();
        fundo = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel22 = new javax.swing.JLabel();
        jComboBox13 = new javax.swing.JComboBox();
        fundo1 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

        jPanel1.setLayout(null);

        tfPaciente.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));
        tfPaciente.setEnabled(false);
        tfPaciente.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                tfPacienteActionPerformed(evt);
            }
        });
        jPanel1.add(tfPaciente);
        tfPaciente.setBounds(130, 110, 480, 20);

        btExcluir.setBackground(new java.awt.Color(0, 153, 153));
        btExcluir.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        btExcluir.setForeground(new java.awt.Color(255, 255, 255));
        btExcluir.setMnemonic('E');
        btExcluir.setText("EXCLUIR");
        btExcluir.setToolTipText("Excluir");
        btExcluir.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btExcluirActionPerformed(evt);
            }
        });
        jPanel1.add(btExcluir);
        btExcluir.setBounds(530, 550, 85, 30);

        btNovo1.setBackground(new java.awt.Color(0, 153, 153));
        btNovo1.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        btNovo1.setForeground(new java.awt.Color(255, 255, 255));
        btNovo1.setMnemonic('N');
        btNovo1.setText("NOVO");
        btNovo1.setToolTipText("Novo");
        btNovo1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btNovo1ActionPerformed(evt);
            }
        });
        jPanel1.add(btNovo1);
        btNovo1.setBounds(250, 550, 70, 30);

        btSalvar1.setBackground(new java.awt.Color(0, 153, 153));
        btSalvar1.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        btSalvar1.setForeground(new java.awt.Color(255, 255, 255));
        btSalvar1.setMnemonic('S');
        btSalvar1.setText("SALVAR");
        btSalvar1.setToolTipText("Salvar");
        btSalvar1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btSalvar1ActionPerformed(evt);
            }
        });
        jPanel1.add(btSalvar1);
        btSalvar1.setBounds(330, 550, 83, 30);

        btSair1.setBackground(new java.awt.Color(0, 153, 153));
        btSair1.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        btSair1.setForeground(new java.awt.Color(255, 255, 255));
        btSair1.setMnemonic('S');
        btSair1.setText("SAIR");
        btSair1.setToolTipText("Sair");
        btSair1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btSair1ActionPerformed(evt);
            }
        });
        jPanel1.add(btSair1);
        btSair1.setBounds(620, 550, 80, 30);

        btPesquisar.setBackground(new java.awt.Color(0, 153, 153));
        btPesquisar.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        btPesquisar.setForeground(new java.awt.Color(255, 255, 255));
        btPesquisar.setMnemonic('P');
        btPesquisar.setText("PESQUISAR");
        btPesquisar.setToolTipText("Pesquisar");
        btPesquisar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btPesquisarActionPerformed(evt);
            }
        });
        jPanel1.add(btPesquisar);
        btPesquisar.setBounds(420, 550, 103, 30);

        btPesquisarPaciente1.setBackground(new java.awt.Color(0, 153, 153));
        btPesquisarPaciente1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/sys/donto/imagens/Search 16.png"))); // NOI18N
        btPesquisarPaciente1.setToolTipText("Pesquisar Paciente");
        btPesquisarPaciente1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btPesquisarPaciente1ActionPerformed(evt);
            }
        });
        jPanel1.add(btPesquisarPaciente1);
        btPesquisarPaciente1.setBounds(620, 110, 37, 25);

        btNovoPaciente1.setBackground(new java.awt.Color(0, 153, 153));
        btNovoPaciente1.setForeground(new java.awt.Color(0, 153, 153));
        btNovoPaciente1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/sys/donto/imagens/add-16.png"))); // NOI18N
        btNovoPaciente1.setToolTipText("Novo Paciente");
        btNovoPaciente1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btNovoPaciente1ActionPerformed(evt);
            }
        });
        jPanel1.add(btNovoPaciente1);
        btNovoPaciente1.setBounds(660, 110, 37, 25);

        jLabel3.setText("Qual queixa?");
        jLabel3.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
        jPanel1.add(jLabel3);
        jLabel3.setBounds(40, 140, 80, 14);

        jLabel4.setText("Sofre alguma Doença?");
        jLabel4.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
        jPanel1.add(jLabel4);
        jLabel4.setBounds(100, 170, 130, 14);

        jLabel8.setFont(new java.awt.Font("Tahoma", 1, 24)); // NOI18N
        jLabel8.setForeground(new java.awt.Color(255, 255, 255));
        jLabel8.setText("ANAMNESE");
        jLabel8.setFocusable(false);
        jPanel1.add(jLabel8);
        jLabel8.setBounds(210, 40, 360, 40);

        jlPaciente1.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        jlPaciente1.setText("PACIENTE:");
        jPanel1.add(jlPaciente1);
        jlPaciente1.setBounds(60, 110, 70, 15);

        jLabel1.setText("Se SIM, qual?");
        jLabel1.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
        jPanel1.add(jLabel1);
        jLabel1.setBounds(310, 200, 80, 14);

        tfSangue.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));
        tfSangue.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                tfSangueActionPerformed(evt);
            }
        });
        jPanel1.add(tfSangue);
        tfSangue.setBounds(230, 410, 70, 20);

        cbDoenca.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "--", "Sim", "Não" }));
        cbDoenca.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cbDoencaActionPerformed(evt);
            }
        });
        jPanel1.add(cbDoenca);
        cbDoenca.setBounds(230, 170, 70, 20);

        tfQueixa.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));
        tfQueixa.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                tfQueixaActionPerformed(evt);
            }
        });
        jPanel1.add(tfQueixa);
        tfQueixa.setBounds(130, 140, 570, 20);

        jLabel9.setText("Está em tratamento Médico?");
        jLabel9.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
        jPanel1.add(jLabel9);
        jLabel9.setBounds(70, 200, 160, 14);

        cbTratamento.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "--", "Sim", "Não" }));
        cbTratamento.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cbTratamentoActionPerformed(evt);
            }
        });
        jPanel1.add(cbTratamento);
        cbTratamento.setBounds(230, 200, 70, 20);

        tfTratamento.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));
        tfTratamento.setEnabled(false);
        tfTratamento.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                tfTratamentoActionPerformed(evt);
            }
        });
        jPanel1.add(tfTratamento);
        tfTratamento.setBounds(390, 200, 310, 20);

        jLabel10.setText("Toma Medicamentos?");
        jLabel10.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
        jPanel1.add(jLabel10);
        jLabel10.setBounds(100, 230, 130, 14);

        cbMedicamentos.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "--", "Sim", "Não" }));
        cbMedicamentos.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cbMedicamentosActionPerformed(evt);
            }
        });
        jPanel1.add(cbMedicamentos);
        cbMedicamentos.setBounds(230, 230, 70, 20);

        tfMedicamento.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));
        tfMedicamento.setEnabled(false);
        tfMedicamento.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                tfMedicamentoActionPerformed(evt);
            }
        });
        jPanel1.add(tfMedicamento);
        tfMedicamento.setBounds(390, 230, 310, 20);

        jLabel12.setText("Problemas com anestesia?");
        jLabel12.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
        jPanel1.add(jLabel12);
        jLabel12.setBounds(310, 320, 160, 14);

        cbAntecedentes.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "--", "Sim", "Não" }));
        cbAntecedentes.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cbAntecedentesActionPerformed(evt);
            }
        });
        jPanel1.add(cbAntecedentes);
        cbAntecedentes.setBounds(230, 260, 70, 20);

        tfAntecedentes.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));
        tfAntecedentes.setEnabled(false);
        tfAntecedentes.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                tfAntecedentesActionPerformed(evt);
            }
        });
        jPanel1.add(tfAntecedentes);
        tfAntecedentes.setBounds(390, 260, 310, 20);

        jLabel15.setText("Alguma Alergia?");
        jLabel15.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
        jPanel1.add(jLabel15);
        jLabel15.setBounds(120, 290, 100, 14);

        cbAlergia.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "--", "Sim", "Não" }));
        cbAlergia.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cbAlergiaActionPerformed(evt);
            }
        });
        jPanel1.add(cbAlergia);
        cbAlergia.setBounds(230, 290, 70, 20);

        tfAlergia.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));
        tfAlergia.setEnabled(false);
        tfAlergia.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                tfAlergiaActionPerformed(evt);
            }
        });
        jPanel1.add(tfAlergia);
        tfAlergia.setBounds(390, 290, 310, 20);

        jLabel14.setText("Problemas de Antecedentes Familiares?");
        jLabel14.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
        jPanel1.add(jLabel14);
        jLabel14.setBounds(10, 260, 210, 14);

        jComboBox5.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "--", "Sim", "Não" }));
        jPanel1.add(jComboBox5);
        jComboBox5.setBounds(230, 260, 70, 20);

        cbHemorragia.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "--", "Sim", "Não" }));
        jPanel1.add(cbHemorragia);
        cbHemorragia.setBounds(230, 350, 70, 20);

        cbAnestesia.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "--", "Sim", "Não" }));
        jPanel1.add(cbAnestesia);
        cbAnestesia.setBounds(470, 320, 70, 20);

        cbCicatricacao.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "--", "Sim", "Não" }));
        jPanel1.add(cbCicatricacao);
        cbCicatricacao.setBounds(230, 320, 70, 20);

        jLabel17.setText("Problemas de Hemorragia?");
        jLabel17.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
        jPanel1.add(jLabel17);
        jLabel17.setBounds(60, 350, 160, 14);

        jLabel18.setText("Problemas de Cicatrização?");
        jLabel18.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
        jPanel1.add(jLabel18);
        jLabel18.setBounds(60, 320, 160, 14);

        jScrollPane1.setViewportView(tfObservacoes);

        jPanel1.add(jScrollPane1);
        jScrollPane1.setBounds(120, 440, 580, 90);

        jLabel19.setText("Problemas Respiratórios?");
        jLabel19.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
        jPanel1.add(jLabel19);
        jLabel19.setBounds(310, 350, 160, 14);

        cbHipertensao.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "--", "Sim", "Não" }));
        jPanel1.add(cbHipertensao);
        cbHipertensao.setBounds(230, 380, 70, 20);

        jLabel21.setFont(new java.awt.Font("Tahoma", 2, 11)); // NOI18N
        jLabel21.setText("OBSERVAÇÕES:");
        jLabel21.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
        jPanel1.add(jLabel21);
        jLabel21.setBounds(20, 440, 120, 14);

        cbRespiratorio.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "--", "Sim", "Não" }));
        jPanel1.add(cbRespiratorio);
        cbRespiratorio.setBounds(470, 350, 70, 20);

        jLabel23.setText("Já se submeteu a Cirurgia?");
        jLabel23.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
        jPanel1.add(jLabel23);
        jLabel23.setBounds(310, 380, 160, 14);

        cbCirurgia.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "--", "Sim", "Não" }));
        jPanel1.add(cbCirurgia);
        cbCirurgia.setBounds(470, 380, 70, 20);

        tfDoenca.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));
        tfDoenca.setEnabled(false);
        tfDoenca.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                tfDoencaActionPerformed(evt);
            }
        });
        jPanel1.add(tfDoenca);
        tfDoenca.setBounds(390, 170, 310, 20);

        jLabel24.setText("Problemas de Hipertensão?");
        jLabel24.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
        jPanel1.add(jLabel24);
        jLabel24.setBounds(60, 380, 160, 14);

        jLabel25.setText("Tipo Sanguineo:");
        jLabel25.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
        jPanel1.add(jLabel25);
        jLabel25.setBounds(120, 410, 100, 14);

        jLabel5.setText("Se SIM, qual?");
        jLabel5.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
        jPanel1.add(jLabel5);
        jLabel5.setBounds(310, 230, 80, 14);

        jLabel6.setText("Se SIM, qual?");
        jLabel6.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
        jPanel1.add(jLabel6);
        jLabel6.setBounds(310, 260, 80, 14);

        jLabel7.setText("Se SIM, qual?");
        jLabel7.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
        jPanel1.add(jLabel7);
        jLabel7.setBounds(310, 290, 80, 14);

        jLabel20.setText("Se SIM, qual?");
        jLabel20.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
        jPanel1.add(jLabel20);
        jLabel20.setBounds(310, 170, 80, 14);

        fundo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/sys/donto/imagens/telaM.jpg"))); // NOI18N
        jPanel1.add(fundo);
        fundo.setBounds(0, 0, 740, 440);

        jLabel2.setText("* Todos os campos são Obrigatórios");
        jPanel1.add(jLabel2);
        jLabel2.setBounds(20, 560, 190, 14);

        jLabel22.setText("Tipo Sangui");
        jPanel1.add(jLabel22);
        jLabel22.setBounds(80, 380, 140, 14);

        jComboBox13.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "--", "Sim", "Não" }));
        jPanel1.add(jComboBox13);
        jComboBox13.setBounds(230, 380, 70, 20);

        fundo1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/sys/donto/imagens/telaM.jpg"))); // NOI18N
        jPanel1.add(fundo1);
        fundo1.setBounds(0, 370, 740, 230);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 739, javax.swing.GroupLayout.PREFERRED_SIZE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, 601, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void limpaCampos(){
        tfAlergia.setText(""); 
        tfDoenca.setText(""); 
        tfAntecedentes.setText(""); 
        tfMedicamento.setText(""); 
        tfObservacoes.setText(""); 
        tfPaciente.setText(""); 
        tfQueixa.setText(""); 
        tfSangue.setText(""); 
        tfTratamento.setText(""); 
        cbAlergia.setSelectedIndex(0);
        cbAnestesia.setSelectedIndex(0);
        cbAntecedentes.setSelectedIndex(0);
        cbCicatricacao.setSelectedIndex(0);
        cbCirurgia.setSelectedIndex(0);
        cbDoenca.setSelectedIndex(0);
        cbHemorragia.setSelectedIndex(0);
        cbHipertensao.setSelectedIndex(0);
        cbMedicamentos.setSelectedIndex(0);
        cbRespiratorio.setSelectedIndex(0);
        cbTratamento.setSelectedIndex(0);
        anamnese = new Anamnese();
        btExcluir.setEnabled(false);
   }
        
    private void btNovo1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btNovo1ActionPerformed
        limpaCampos(); //CHAMA METODO PARA LIMPAR CAMPOS
    }//GEN-LAST:event_btNovo1ActionPerformed

    private void btSalvar1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btSalvar1ActionPerformed

                 if (tfPaciente.getText().equals("")&&tfQueixa.getText().equals("")&&tfSangue.getText().equals("")&&
                         cbAlergia.getSelectedIndex()==0 && cbAnestesia.getSelectedIndex()==0
                         && cbAntecedentes.getSelectedIndex()==0
                 && cbDoenca.getSelectedIndex()==0 && cbCicatricacao.getSelectedIndex()==0
                 && cbCirurgia.getSelectedIndex()==0 && cbHemorragia.getSelectedIndex()==0
                 && cbMedicamentos.getSelectedIndex()==0 && cbHipertensao.getSelectedIndex()==0
                 && cbRespiratorio.getSelectedIndex()==0 && cbTratamento.getSelectedIndex()==0
                 ){
            JOptionPane.showMessageDialog(rootPane, "Informe todos os Campos Obrigatórios");
                 }
            if(cbDoenca.getSelectedIndex()==2){//Se a Opção de ter doença for nao Salva como falso
            anamnese.setSofreDoenca(false);
            }
            if(cbDoenca.getSelectedIndex()==1){//Se a opção for Sim deve Informar qual
                if(tfDoenca.getText().equals("")){
                    JOptionPane.showMessageDialog(rootPane, "Informe Qual Doença");
                }else{
                    anamnese.setSofreDoenca(true);
                    anamnese.setQualDoenca(tfDoenca.getText());
                }
            }
            
            if(cbTratamento.getSelectedIndex()==2){
            anamnese.setTratamentoMedico(false);
            }
            if(cbTratamento.getSelectedIndex()==1){
                if(tfTratamento.getText().equals("")){
                    JOptionPane.showMessageDialog(rootPane, "Informe Qual Tratamento");
                }else{
                    anamnese.setTratamentoMedico(true);
                    anamnese.setQualTratamento(tfTratamento.getText());
                }
            }
            
            if(cbMedicamentos.getSelectedIndex()==2){
            anamnese.setMedicamento(false);
            }
            if(cbMedicamentos.getSelectedIndex()==1){
                if(tfMedicamento.getText().equals("")){
                    JOptionPane.showMessageDialog(rootPane, "Informe Qual Medicamento");
                }else{
                    anamnese.setMedicamento(true);
                    anamnese.setQualMedicamento(tfTratamento.getText());
                }
            }
            
            if(cbAntecedentes.getSelectedIndex()==2){
            anamnese.setAntecendentesFamiliares(false);
            }
            if(cbAntecedentes.getSelectedIndex()==1){
                if(tfAntecedentes.getText().equals("")){
                    JOptionPane.showMessageDialog(rootPane, "Informe Qual Antecedente");
                }else{
                    anamnese.setAntecendentesFamiliares(true);
                    anamnese.setQualAntecedente(tfAntecedentes.getText());
                }
            }
            
            if(cbAlergia.getSelectedIndex()==2){
            anamnese.setAlergia(false);
            }
            if(cbAlergia.getSelectedIndex()==1){
                if(tfAlergia.getText().equals("")){
                    JOptionPane.showMessageDialog(rootPane, "Informe Qual Alergia");
                }else{
                    anamnese.setAlergia(true);
                    anamnese.setQualAlergia(tfAlergia.getText());
                }
            }
            
            if(cbCicatricacao.getSelectedIndex()==2){
            anamnese.setProblemaCicatrizacao(false);
            }
            if(cbCicatricacao.getSelectedIndex()==1){
            anamnese.setProblemaCicatrizacao(true); 
            }
            
            if(cbHemorragia.getSelectedIndex()==2){
            anamnese.setHemorragia(false);
            }
            if(cbHemorragia.getSelectedIndex()==1){
            anamnese.setHemorragia(true); 
            }
                        
            if(cbAnestesia.getSelectedIndex()==2){
            anamnese.setAnestesia(false);
            }
            if(cbAnestesia.getSelectedIndex()==1){
            anamnese.setAnestesia(true); 
            }
                        
            if(cbRespiratorio.getSelectedIndex()==2){
            anamnese.setProblemaRespiratorio(false);
            }
            if(cbRespiratorio.getSelectedIndex()==1){
            anamnese.setProblemaRespiratorio(true); 
            }
                        
            if(cbHipertensao.getSelectedIndex()==2){
            anamnese.setHipertensao(false);
            }
            if(cbHipertensao.getSelectedIndex()==1){
            anamnese.setHipertensao(true); 
            }
                      
            if(cbCirurgia.getSelectedIndex()==2){
            anamnese.setOperado(false);
            }
            if(cbCirurgia.getSelectedIndex()==1){
            anamnese.setOperado(true); 
            }
            
            else{
            anamnese.setQueixa(tfQueixa.getText());
            anamnese.setTipoSanguineo(tfSangue.getText());
            anamnese.setObservacoes(tfObservacoes.getText());
            
            AnamneseDAO dao = new AnamneseDAO();
            dao.salvar(anamnese);
            limpaCampos();
            JOptionPane.showMessageDialog(rootPane, "Anamnese gerada com Sucesso!");

            
        
            }
    }//GEN-LAST:event_btSalvar1ActionPerformed

    private void btSair1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btSair1ActionPerformed
        dispose();
    }//GEN-LAST:event_btSair1ActionPerformed

    private void tfSangueActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_tfSangueActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_tfSangueActionPerformed

    private void tfQueixaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_tfQueixaActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_tfQueixaActionPerformed

    private void tfTratamentoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_tfTratamentoActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_tfTratamentoActionPerformed

    private void tfMedicamentoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_tfMedicamentoActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_tfMedicamentoActionPerformed

    private void tfAntecedentesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_tfAntecedentesActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_tfAntecedentesActionPerformed

    private void tfAlergiaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_tfAlergiaActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_tfAlergiaActionPerformed

    private void tfDoencaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_tfDoencaActionPerformed
        
    }//GEN-LAST:event_tfDoencaActionPerformed

    private void btPesquisarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btPesquisarActionPerformed
        AnamneseDAO dao = new AnamneseDAO();
        List <Anamnese> anamneses = (!tfPaciente.getText().isEmpty() ? dao.pesquisaDescricao(tfPaciente.getText())
            : dao.listar()); //descrição que diz que se o campo descrição estiver vazio ele pega a descrição digitada.

        AnamneseTableModel atm = new AnamneseTableModel(anamneses);

        Object o = telaPesquisa.exibeTela(atm, "Anamnese");

        if (o != null){
            anamnese = new Anamnese();
            anamnese = dao.pesquisaId(Integer.valueOf(String.valueOf(o)));

            tfQueixa.setText(anamnese.getQueixa());
            tfSangue.setText(anamnese.getTipoSanguineo());
            tfPaciente.setText(anamnese.getPaciente().getNome());
            tfObservacoes.setText(anamnese.getQualTratamento());
            tfAlergia.setText(anamnese.getQualAlergia());
            tfAntecedentes.setText(anamnese.getQualAntecedente());
            tfDoenca.setText(anamnese.getQualDoenca());
            tfMedicamento.setText(anamnese.getQualMedicamento());
            tfTratamento.setText(anamnese.getQualTratamento());
            
            if(anamnese.getSofreDoenca()==true){
                cbDoenca.setSelectedIndex(1);
            }else{
                cbDoenca.setSelectedIndex(2);
            }
            if(anamnese.getTratamentoMedico()==true){
                cbTratamento.setSelectedIndex(1);
            }else{
                cbTratamento.setSelectedIndex(2);
            }
            if(anamnese.getMedicamento()==true){
                cbMedicamentos.setSelectedIndex(1);
            }else{
                cbMedicamentos.setSelectedIndex(2);
            }
            if(anamnese.getAntecendentesFamiliares()==true){
                cbAntecedentes.setSelectedIndex(1);
            }else{
                cbAntecedentes.setSelectedIndex(2);
            }
            if(anamnese.getAlergia()==true){
                cbAlergia.setSelectedIndex(1);
            }else{
                cbAlergia.setSelectedIndex(2);
            }
            if(anamnese.getProblemaCicatrizacao()==true){
                cbCicatricacao.setSelectedIndex(1);
            }else{
                cbCicatricacao.setSelectedIndex(2);
            }
            if(anamnese.getHemorragia()==true){
                cbHemorragia.setSelectedIndex(1);
            }else{
                cbHemorragia.setSelectedIndex(2);
            }
            if(anamnese.getHipertensao()==true){
                cbHipertensao.setSelectedIndex(1);
            }else{
                cbHipertensao.setSelectedIndex(2);
            }
            if(anamnese.getAnestesia()==true){
                cbAnestesia.setSelectedIndex(1);
            }else{
                cbAnestesia.setSelectedIndex(2);
            }
            if(anamnese.getProblemaRespiratorio()==true){
                cbRespiratorio.setSelectedIndex(1);
            }else{
                cbRespiratorio.setSelectedIndex(2);
            }
            if(anamnese.getOperado()==true){
                cbCirurgia.setSelectedIndex(1);
            }else{
                cbCirurgia.setSelectedIndex(2);
            }

           btExcluir.setEnabled(true);
        }
    }//GEN-LAST:event_btPesquisarActionPerformed

    private void tfPacienteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_tfPacienteActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_tfPacienteActionPerformed

    private void btPesquisarPaciente1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btPesquisarPaciente1ActionPerformed
        PacienteDAO dao = new PacienteDAO();// butão de pesquisa de estado.
        List<Paciente> lista = dao.listar();
        PacienteTableModel ptm = new PacienteTableModel(lista);
        Object o = telaPesquisa.exibeTela(ptm, "paciente");
        Paciente p;
        if (o != null) {
            p = dao.pesquisaId(Integer.valueOf(String.valueOf(o)));
            anamnese.setPaciente(p);
            tfPaciente.setText(p.getNome());
        }         // TODO add your handling code here:
    }//GEN-LAST:event_btPesquisarPaciente1ActionPerformed

    private void btNovoPaciente1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btNovoPaciente1ActionPerformed
        telaPaciente tp = new telaPaciente();
        tp.setVisible(true);
    }//GEN-LAST:event_btNovoPaciente1ActionPerformed

    private void cbDoencaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbDoencaActionPerformed
        if(cbDoenca.getSelectedIndex()==1){
            tfDoenca.setEnabled(true);
        }else{
            tfDoenca.setEnabled(false);
        }
        
    }//GEN-LAST:event_cbDoencaActionPerformed

    private void cbTratamentoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbTratamentoActionPerformed
        if(cbTratamento.getSelectedIndex()==1){
            tfTratamento.setEnabled(true);
        }else{
            tfTratamento.setEnabled(false);
        }
    }//GEN-LAST:event_cbTratamentoActionPerformed

    private void cbMedicamentosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbMedicamentosActionPerformed
        if(cbMedicamentos.getSelectedIndex()==1){
            tfMedicamento.setEnabled(true);
        }else{
            tfMedicamento.setEnabled(false);
        }
    }//GEN-LAST:event_cbMedicamentosActionPerformed

    private void cbAntecedentesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbAntecedentesActionPerformed
        if(cbAntecedentes.getSelectedIndex()==1){
            tfAntecedentes.setEnabled(true);
        }else{
            tfAntecedentes.setEnabled(false);
        }
    }//GEN-LAST:event_cbAntecedentesActionPerformed

    private void cbAlergiaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbAlergiaActionPerformed
        if(cbAlergia.getSelectedIndex()==1){
            tfAlergia.setEnabled(true);
        }else{
            tfAlergia.setEnabled(false);
        }
    }//GEN-LAST:event_cbAlergiaActionPerformed

    private void btExcluirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btExcluirActionPerformed
        if (JOptionPane.showConfirmDialog(rootPane,
            "Deseja excluir Anamnese?",
            "Excluir?", JOptionPane.YES_NO_OPTION)
        == JOptionPane.YES_OPTION) {

        AnamneseDAO dao = new AnamneseDAO();
        dao.remover(anamnese);
        limpaCampos();

        JOptionPane.showMessageDialog(rootPane, "Anamnese Excluída com Sucesso!");
        }else{
            limpaCampos();
        }

    }//GEN-LAST:event_btExcluirActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(telaAnamnese.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(telaAnamnese.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(telaAnamnese.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(telaAnamnese.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new telaAnamnese().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btExcluir;
    private javax.swing.JButton btNovo1;
    private javax.swing.JButton btNovoPaciente1;
    private javax.swing.JButton btPesquisar;
    private javax.swing.JButton btPesquisarPaciente1;
    private javax.swing.JButton btSair1;
    private javax.swing.JButton btSalvar1;
    private javax.swing.JComboBox cbAlergia;
    private javax.swing.JComboBox cbAnestesia;
    private javax.swing.JComboBox cbAntecedentes;
    private javax.swing.JComboBox cbCicatricacao;
    private javax.swing.JComboBox cbCirurgia;
    private javax.swing.JComboBox cbDoenca;
    private javax.swing.JComboBox cbHemorragia;
    private javax.swing.JComboBox cbHipertensao;
    private javax.swing.JComboBox cbMedicamentos;
    private javax.swing.JComboBox cbRespiratorio;
    private javax.swing.JComboBox cbTratamento;
    private javax.swing.JLabel fundo;
    private javax.swing.JLabel fundo1;
    private javax.swing.JComboBox jComboBox13;
    private javax.swing.JComboBox jComboBox5;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel18;
    private javax.swing.JLabel jLabel19;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel20;
    private javax.swing.JLabel jLabel21;
    private javax.swing.JLabel jLabel22;
    private javax.swing.JLabel jLabel23;
    private javax.swing.JLabel jLabel24;
    private javax.swing.JLabel jLabel25;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JLabel jlPaciente1;
    private javax.swing.JTextField tfAlergia;
    private javax.swing.JTextField tfAntecedentes;
    private javax.swing.JTextField tfDoenca;
    private javax.swing.JTextField tfMedicamento;
    private javax.swing.JTextPane tfObservacoes;
    private javax.swing.JTextField tfPaciente;
    private javax.swing.JTextField tfQueixa;
    private javax.swing.JTextField tfSangue;
    private javax.swing.JTextField tfTratamento;
    // End of variables declaration//GEN-END:variables
}
